﻿<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>登录-伯乐网</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" type="text/css" href="style/css/style.css"/>

    <!--<script id="allmobilize" charset="utf-8" src="style/js/allmobilize.min.js"></script>-->
    <script src="style/js/jquery.1.10.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="style/js/jquery.lib.min.js"></script>
    <script type="text/javascript" src="style/js/core.min.js"></script>
    <!--layer.js-->
    <script type="text/javascript" src="style/js/layer/layer.js"></script>
</head>

<body id="login_bg">
<div class="login_wrapper" style="padding-top: 50px;">
    <div class="login_header">
        <a href="h/"><img src="style/images/logo_white.png" width="285" height="62" alt="伯乐网"/></a>
        <div id="cloud_s"><img src="style/images/cloud_s.png" width="81" height="52" alt="cloud"/></div>
        <div id="cloud_m"><img src="style/images/cloud_m.png" width="136" height="95" alt="cloud"/></div>
    </div>

    <input type="hidden" id="resubmitToken" value=""/>
    <div class="login_box">
        <form id="loginForm" action="index.html">
            <!--电话号码-->
            <input type="text" id="email" class="phone" name="email" value="" tabindex="1" placeholder="请输入电话号码"/>
            <!--密码-->
            <input type="password" id="password" class="pwd" name="password" tabindex="2" placeholder="请输入密码"/>
            <!--记住密码-->
            <label class="fl" for="remember">
                <input type="checkbox" id="remember" value="" checked="checked" name="autoLogin"/> 记住我
            </label>
            <!--忘记密码-->
            <a href="/resetPage" class="fr">忘记密码？</a>

            <input type="button" id="submitLogin" class="login" value="登 &nbsp; &nbsp; 录"/>
            <!--<a style="color:#fff;" href="index.html" class="submitLogin" title="登 &nbsp; &nbsp; 录" />登 &nbsp; &nbsp; 录</a>-->

        </form>
        <div class="login_right">
            <div>还没有伯乐帐号？</div>
            <a href="/registerPage" class="registor_now">立即注册</a>
        </div>
    </div>
    <div class="login_box_btm"></div>
</div>

<script>
    //点击登录按钮
    $(".login").click(function () {
        //获取电话号码
        var phone = $(".phone").val().trim();
        //获取密码
        var pwd = $(".pwd").val().trim();

        if (phone == null || phone == "") {
            layer.msg("请输入手机号！");
            return false;
        }
        if (!(/^1[3456789]\d{9}$/.test(phone))) {
            layer.msg("手机号有误!");
            return false;
        }

        if (pwd == null || pwd == "") {
            layer.msg("请输入密码!");
            return false;
        }
        if (pwd.length < 6 || pwd.length > 16) {
            layer.msg("密码应长度介于6~16位!");
            return false;
        }
        //数据校验成功，向后端发送和请求
        $.ajax({
            type: "post",
            url: "/login/" + phone + "/" + pwd,
            success: function (result) {
                //成功的回调函数
                if (result.code == -1) {
                    layer.msg("用户名或密码错误!");
                } else {
                    //登陆成功，判断用户类型，不同用户跳转到不同页面
                    //获取用户类型
                    var usertype = result.data.userType;
                    if(usertype=="p"){
                    	//如果是普通用户，则跳转到首页
						location.href="/";
						return false;
					}
                    if(usertype=="q"){
                    	//如果是企业用户，则判断其是否认证
                        var authentication=result.data.authentication;
                        if(authentication==0){
                            //未认证
                            location.href="/index01?"+"userId="+result.data.id;
                        }else if(authentication==1){
                            //已认证
                            location.href="/myhome?"+"userId="+result.data.id;
                        }
						return false;
					}
                }
            }
        });
    });
</script>
</body>

</html>